package org.xg.study.servlet;

import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author CMG
 * @version 1.0
 * @description
 * @cLassName MyServlet1
 * @date 2021/9/23 10:08
 **/
public class MyServlet1 extends GenericServlet {
    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        //设置字符集
        servletResponse.setContentType("text/html;charset=UTF-8");
        //使用PrintWriter.write()方法向前台输出内容
        PrintWriter printWriter = servletResponse.getWriter();
        printWriter.write("Hello World");
        printWriter.close();
    }
}
